package com.itheima.admin.service.impl;

import com.alibaba.cloud.commons.lang.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.admin.dto.AdSensitiveDto;
import com.itheima.admin.mapper.AdSensitiveMapper;
import com.itheima.admin.pojo.AdSensitive;
import com.itheima.admin.service.AdSensitiveService;
import com.itheima.common.vo.PageResultVo;
import org.springframework.stereotype.Service;

/**
 * @description <p>敏感词信息 业务实现</p>
 *
 * @version 1.0
 * @package com.itheima.admin.service.impl
 */
@Service
public class AdSensitiveServiceImpl extends ServiceImpl<AdSensitiveMapper, AdSensitive> implements AdSensitiveService {

    @Override
    public PageResultVo findPage(AdSensitiveDto adSensitiveDto) {
        //创建一个分页查询的条件对象
        IPage<AdSensitive> iPage = new Page<>(adSensitiveDto.getPage(),adSensitiveDto.getSize());
        //创建条件对象
        LambdaQueryWrapper<AdSensitive> lwq = new LambdaQueryWrapper<>();
        //添加查询条件
        lwq.eq(StringUtils.isNotEmpty(adSensitiveDto.getSensitives()),AdSensitive::getSensitives,adSensitiveDto.getSensitives());
        //进行分页查询
        this.page(iPage,lwq);
        return PageResultVo.pageResult(adSensitiveDto.getPage(),adSensitiveDto.getSize(),iPage.getTotal(),iPage.getRecords());
    }
}
